<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";
import dayjs from 'dayjs'

export default {
  name: "APIqueryDbquanwangfuhechart",
  components: {},
  data() {
    return {};
  },
  computed: {
    ishistory: function () {
      return this.$store.state.daping.ishistorytime;
    },
    timerangarr: function () {
      return this.$store.state.daping.timepick;
    },
  },
  watch: {},
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APIqueryDbquanwangfuhechart"] !=
        undefined
      ) {
        return;
      }

      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["APIqueryDbquanwangfuhechart"] = [
        { interval: interval },
      ];
    },
    loadData() {
      let day = dayjs().format("YYYY-MM-DD")

      let st = dayjs(day + ' 00:00:00').unix()
      let et = dayjs(day + ' 23:59:59').unix()
      let queryJson = {
        queries: [
          {
            metric: "*",
            schema: "view",
          },
        ],
        table: "pipenet_f_daily_realtime",
        orderBy: "aligntime",
        endTime: et,
        startTime: st,
      };

      axios.post("/open/queryDb", queryJson).then((res) => {
        if (true) {
          //如果有则获取200中的结果
          if (res.code == 200) {
            this.$store.state.daping.quanwangfuhe = res.data
          }
        }
      });
    },
  },
};
</script>
<style lang='scss' scoped>
</style>